namespace ChuTiJingTai.Models
{
    /// <summary>
    /// API配置模型
    /// </summary>
    public class ApiConfig
    {
        /// <summary>
        /// 模型服务商
        /// </summary>
        public string Provider { get; set; } = "阿里百炼";

        /// <summary>
        /// API Key
        /// </summary>
        public string ApiKey { get; set; } = string.Empty;

        /// <summary>
        /// API基础地址
        /// </summary>
        public string BaseUrl { get; set; } = string.Empty;

        /// <summary>
        /// 模型名称
        /// </summary>
        public string ModelName { get; set; } = string.Empty;

        /// <summary>
        /// 最后测试时间
        /// </summary>
        public DateTime? LastTestTime { get; set; }

        /// <summary>
        /// 测试是否成功
        /// </summary>
        public bool IsTestSuccess { get; set; }
    }

    /// <summary>
    /// 支持的模型服务商
    /// </summary>
    public static class ModelProviders
    {
        public const string AliBailian = "阿里百炼";
        public const string DeepSeek = "DeepSeek";
        public const string OpenAI = "OpenAI";
        public const string Volcano = "火山平台";

        public static List<string> GetAll() => new() { AliBailian, DeepSeek, OpenAI, Volcano };
        
        /// <summary>
        /// 获取服务商的默认配置信息
        /// </summary>
        public static ProviderInfo GetProviderInfo(string provider)
        {
            return provider switch
            {
                AliBailian => new ProviderInfo
                {
                    Name = "阿里百炼",
                    BaseUrl = "https://dashscope.aliyuncs.com/compatible-mode/v1",
                    ApiKeyHint = "在阿里云百炼控制台创建API KEY",
                    ModelNameHint = "如：qwen-plus, qwen-turbo",
                    DocumentUrl = "https://help.aliyun.com/zh/dashscope/developer-reference/api-details"
                },
                DeepSeek => new ProviderInfo
                {
                    Name = "DeepSeek",
                    BaseUrl = "https://api.deepseek.com/v1",
                    ApiKeyHint = "在DeepSeek控制台获取API KEY",
                    ModelNameHint = "如：deepseek-chat, deepseek-coder",
                    DocumentUrl = "https://platform.deepseek.com/api-docs/"
                },
                OpenAI => new ProviderInfo
                {
                    Name = "OpenAI",
                    BaseUrl = "https://api.openai.com/v1",
                    ApiKeyHint = "在OpenAI平台获取API KEY",
                    ModelNameHint = "如：gpt-3.5-turbo, gpt-4",
                    DocumentUrl = "https://platform.openai.com/docs/api-reference"
                },
                Volcano => new ProviderInfo
                {
                    Name = "火山平台",
                    BaseUrl = "https://ark.cn-beijing.volces.com/api/v3",
                    ApiKeyHint = "在火山引擎控制台获取API KEY",
                    ModelNameHint = "如：ep-xxxxx（端点ID）",
                    DocumentUrl = "https://www.volcengine.com/docs/82379"
                },
                _ => new ProviderInfo { Name = provider }
            };
        }
    }

    /// <summary>
    /// 服务商信息
    /// </summary>
    public class ProviderInfo
    {
        public string Name { get; set; } = string.Empty;
        public string BaseUrl { get; set; } = string.Empty;
        public string ApiKeyHint { get; set; } = string.Empty;
        public string ModelNameHint { get; set; } = string.Empty;
        public string DocumentUrl { get; set; } = string.Empty;
    }
} 